<template>
<!-- 歌单专用 -->
  <ul class="musicBox">
    <router-link
      :to="{ name: 'songsheetdetail', query: { id: item.id } }"
      tag="li"
      v-for="(item, index) in content"
      :key="index"
      class="musicItem"
    >
      <div class="imgBox">
        <img class="musicImg" :src="item.coverImgUrl" alt="" />
        <div class="musicplayNumBox">
          <div class="headset"></div>
          <span class="palyNumBox"
            >{{ parseInt(item.playCount / 10000) }}万</span
          >
          <div class="playBtn" @click.stop="PlayClick(item.id)"></div>
        </div>
      </div>
      <p class="itemName">{{ item.name }}</p>
    </router-link>
  </ul>
</template>

<script>
import { songSheetDetail } from "@/api";
import { mapActions } from "vuex";
export default {
  props: {
    content: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    ...mapActions("musicStore", ["songSheetPlay"]),
    PlayClick(id) {
      //直接点击播放
      songSheetDetail({ id }).then((res) => {
        this.songSheetPlay(res.playlist.tracks);
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.musicBox {
  margin: 20px 0 0 -50px;
  .musicItem {
    display: inline-block;
    width: 140px;
    height: 188px;
    font-size: 14px;
    overflow: hidden;
    // padding: 0 25px 30px 25px;
    padding: 0 0 30px 49px;
    .imgBox {
      width: 140px;
      height: 140px;
      position: relative;
      .musicImg {
        width: 100%;
        height: 100%;
      }
      .musicplayNumBox {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        font-size: 12px;
        height: 27px;
        background-position: 0 -537px;
        color: #ccc;
        background-image: url("./../../assets/imges/background.png");
        display: flex;
        align-items: center;
        .headset {
          width: 14px;
          height: 11px;
          vertical-align: middle;
          background-position: 0 -24px;
          margin: 9px 5px 9px 10px;
          display: inline-block;
          background-image: url("./../../assets/imges/btnIcon.png");
        }
        .playBtn {
          width: 16px;
          background-image: url("./../../assets/imges/btnIcon.png");
          height: 17px;
          display: inline-block;
          padding-right: 10px;
        }
        .palyNumBox {
          flex: 1;
        }
      }
    }
    .itemName {
      margin: 8px 0 3px;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
    }
  }
}
</style>